home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-168.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  43.6 KB  |  1,140 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Sun, 16 Aug 92       Volume 1 : Issue 168
  2.  
  3. Today's Topics:
  4.  
  5.     Dispose of my relocatable blocks?
  6.     "remote" app termination
  7.     How do I get a Spinning Watch?
  8.     undocumented low-memory globals
  9.     MPW on SE
  10.     MPW Scripting Q - answer
  11.     Debugger for daemons?
  12.     Dragging Icons...HELP!
  13.     DSAT error #28, ThinkPascal, and MacsBug (weird)
  14.     When to HLock (and not HLock) handles
  15.  
  16.  
  17.  
  18. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  19.  
  20. The digest is a collection of article threads from the internet newsgroup
  21. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  22. regularly and want an archive of the discussions.  If you don't know what a
  23. newsgroup is, you probably don't have access to it.  Ask your systems
  24. administrator(s) for details.  (This means you can't post questions to the
  25. digest.)
  26.  
  27. Each issue of the digest contains one or more sets of articles (called
  28. threads), with each set corresponding to a 'discussion' of a particular
  29. subject.  The articles are not edited; all articles included in this digest
  30. are in their original posted form (as received by our news server at
  31. cs.uoregon.edu).  Article threads are not added to the digest until the last
  32. article added to the thread is at least one month old (this is to ensure that
  33. the thread is dead before adding it to the digest).  Article threads that
  34. consist of only one message are generally not included in the digest.
  35.  
  36. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  37. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  38. file /pub/mac/csmp-digest/README before downloading any files.  The most
  39. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  40. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  41. archive has a mail server; send a message with the text '$MACarch help' (no
  42. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  43.  
  44. The digest is also available via email.  Just send a note saying that you
  45. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  46. automatically receive each new issue as it is created.  Sorry, back issues
  47. are not available through the mailing list.
  48.  
  49. Send administrative mail to mkelly@cs.uoregon.edu.
  50.  
  51.  
  52. -------------------------------------------------------
  53.  
  54. From: djpegg@utkvx1.utk.edu (PEGG, DAVID J)
  55. Subject: Dispose of my relocatable blocks?
  56. Date: 10 Jul 92 20:11:00 GMT
  57. Organization: University of Tennessee Computing Center
  58.  
  59. I've been having trouble getting my program to quit without bombing.  I posted
  60. a note here to find out why, and several people advised me to deallocate my
  61. relocatable blocks. As far as I can tell, then, I need to call DisposHandle()
  62. (or a function like DisposDialog() that calls DisposHandle() ).   Do I need to
  63. do this for every handle?  Also, I'm told that the system will clean up some of
  64. my memory mess upon quitting.  There's no problem with it trying to dispose of
  65. a handle I already disposed of, is there?
  66.  
  67. Another (possibly unrelated) question: what is an F-line? I have been getting
  68. system errors that say "bad F-line instruction."  What does that mean?
  69.  
  70. Thanks for helping out a beginner,
  71.    -Mike
  72.  
  73. +++++++++++++++++++++++++++
  74.  
  75. From: daven@notable.com (Dave Newman)
  76. Date: Sun, 12 Jul 92 11:59:52 PST
  77. Organization: Notable Technologies, Inc.
  78.  
  79.  
  80. In article <10JUL199215111844@utkvx1.utk.edu> (comp.sys.mac.programmer), djpegg@utkvx1.utk.edu (PEGG, DAVID J) writes:
  81. | I've been having trouble getting my program to quit without bombing.  I posted
  82. | a note here to find out why, and several people advised me to deallocate my
  83. | relocatable blocks. As far as I can tell, then, I need to call DisposHandle()
  84. | (or a function like DisposDialog() that calls DisposHandle() ).   Do I need to
  85. | do this for every handle?  Also, I'm told that the system will clean up some of
  86. | my memory mess upon quitting.  There's no problem with it trying to dispose of
  87. | a handle I already disposed of, is there?
  88.  
  89. There's a BIG problem with disposing a handle you've already disposed. It
  90. causes the heap's private data structures to become corrupted. This eventually
  91. leads to a crash, often mysterious, and far removed from the cause.
  92.  
  93. As a general rule of thumb, you should always dispose of handles the moment
  94. you know they are no longer needed and can be safely disposed of. Waiting
  95. to "quit" time is not advisable for three good reasons:
  96.  
  97. 1) You will have a large tangled web of handles to sift through and try
  98. to write code for disposing them. You're better off tackling this problem
  99. by disposing of them near the code that uses them.
  100.  
  101. 2) Leaving handles around causes memory to "leak". Your heap eventually
  102. fills to the point that it has no memory left and you'll crash with a
  103. heap out of memory error.
  104.  
  105. 3) At "quit" time you may not have enough memory left load the CODE
  106. segments needed to dispose of the handles that are causing you to not have
  107. enough memory. (Though well written programs try to see to it that the
  108. "quit" code is always in memory just in case this sort of thing happens.)
  109.  
  110. | Another (possibly unrelated) question: what is an F-line? I have been getting
  111. | system errors that say "bad F-line instruction."  What does that mean?
  112.  
  113. Means the CPU started executing garbage. One such cause is disposing of
  114. a handle twice. This will result in the heap becoming corrupt. Heaps contain
  115. data and code. Corrupted heaps often will have their handles to data and
  116. code blocks scrambled. Eventually the OS goes to execute a code block that
  117. isn't and *bang* you get the "bad F-line instruction" message when the CPU
  118. starts to execute a data block.
  119.  
  120. - --Dave
  121.  
  122. - -----------------------------------------------------------
  123. Dave Newman                 |  AOL:      AFC Tinman
  124. Artillery Spotter           |  ALink:    TINMAN
  125. Notable Technologies, Inc.  |  CIS:      70743,3323
  126. Voice:    510.208.4449      |  internet: daven@notable.com
  127. FAX:      510.444.4493      |  
  128. - -----------------------------------------------------------
  129.  
  130. ---------------------------
  131.  
  132. From: howie@cfarer.boeing.com (Howard Modell)
  133. Subject: "remote" app termination
  134. Date: 10 Jul 92 16:48:59 GMT
  135. Organization: Boeing Defense and Space Group
  136.  
  137. This is a System 6.0.x related question.
  138.  
  139. How can one application cause another application to "quit"?  I have a
  140. situation in which one app (in this case SuperCard) is going to launch
  141. another (MS Word), and I would like to be able to do something while
  142. SuperCard is active to terminate Word.  Multifinder/Finder does this during
  143. Restart and Shutdown, so there is *some* mechanism.  Can someone enlighten
  144. me?
  145.  
  146. +---All opinions expressed are my own, and *NOT* my employers!---+
  147.     Howard Modell, Boeing Defence & Space Group, Seattle, WA
  148.     Email: howie@cfarer.boeing.com,  h.modell@ieee.org,
  149.          hmodell@polari.online.com, 72376.252@compuserve.com
  150.  
  151. +++++++++++++++++++++++++++
  152.  
  153. From: leonardr@ccs.itd.umich.edu
  154. Organization: Campus Computing Sites, University of Michigan-Ann Arbor
  155. Date: Sun, 12 Jul 92 19:07:25 GMT
  156.  
  157. In article <howie-100792095112@134.52.54.217> howie@cfarer.boeing.com (Howard Modell) writes:
  158. >This is a System 6.0.x related question.
  159. >
  160. >How can one application cause another application to "quit"?  I have a
  161. >situation in which one app (in this case SuperCard) is going to launch
  162. >another (MS Word), and I would like to be able to do something while
  163. >SuperCard is active to terminate Word.  Multifinder/Finder does this during
  164. >Restart and Shutdown, so there is *some* mechanism.  Can someone enlighten
  165. >me?
  166. >
  167.     There is no simple way to do this.  In fact, what MF does when the user
  168. chooses "Restart/Shutdown" is a process known as "MultiFinder Puppet Strings"
  169. where MF (what we now call the Process Manager) will go to each application
  170. and FAKE IT into thinking that the user just choose the Quit menu item.  Then
  171. each application quits happily.
  172.  
  173.     It is possible to duplicate the "MF Puppet Strings" using a Driver
  174. to perform the "faking the quit" actions and then signalling the driver from
  175. the application (and of course installing & removing it too).  Oh, the 
  176. driver would have to patch _MenuSelect & fake a mouseDown inMenuBar.
  177.  
  178.  
  179. - -- 
  180. - -----------------------------------------------------------------------
  181. Leonard Rosenthol          Internet: leonardr@ccs.itd.umich.edu
  182. Director of Advanced Technology   AppleLink: MACgician
  183. Aladdin Systems, inc.          GEnie:     MACgician
  184.  
  185. ---------------------------
  186.  
  187. From: Jerome Chan <yjc@po.cwru.edu>
  188. Subject: How do I get a Spinning Watch?
  189. Organization: Alethea, The Twilight World!
  190. Date: Sun, 12 Jul 92 19:57:17 GMT
  191.  
  192.   How do I change the icon to a spinning watch?
  193.  
  194.   I've looked into my system file and I don't see any watch Cursors
  195. anywhere or acurs or curs resources. (System 7.0.1, IIsi). Is it hidden
  196. away in ROM? What are their resource IDs??
  197.  
  198. - ---
  199.  Fading
  200.  
  201. +++++++++++++++++++++++++++
  202.  
  203. From: jbush@magnus.acs.ohio-state.edu (J Eric Bush)
  204. Organization: The Ohio State University
  205. Date: Sun, 12 Jul 1992 21:53:54 GMT
  206.  
  207. In article <1992Jul12.195717.118@usenet.ins.cwru.edu> Jerome Chan <yjc@po.cwru.
  208. edu> writes:
  209. >  How do I change the icon to a spinning watch?
  210. >
  211. >  I've looked into my system file and I don't see any watch Cursors
  212. >anywhere or acurs or curs resources. (System 7.0.1, IIsi). Is it hidden
  213. >away in ROM? What are their resource IDs??
  214. >
  215.  
  216. The cursor resource is located in the Finder, not in the System file.  I have
  217. done this within applications by copying the cursors from the Finder to my
  218. applications resource fork and then using SetCursor() from within Think Pascal.
  219.  I don't know what it would be in Think C.  Here is some code to do it:
  220.  
  221. procedure adjust_cursor;
  222.  var
  223.   cursor: CursHandle;
  224.  begin
  225.   cursor := GetCursor(cursorID);
  226.   SetCursor(cursor^^);
  227.   cursorID := cursorID + 1;
  228.   if cursorID > 305 then
  229.    cursorID := 300;
  230.  end;
  231.  
  232. cursorID would be a global which would initially be set to the first cursor in 
  233. your animation cycle.  You would adjust the 305 to be equal to the last number 
  234. in your animation cycle.  For this example, the cursor ID's were 
  235. 300,301,302,303,304, and 305.
  236.  
  237. Eric
  238. - -- 
  239. - ------------------------------------------------------------------------------
  240. J. Eric Bush
  241. Internet: jbush@magnus.acs.ohio-state.edu   ProLine: eric@pro-tcc.cts.com
  242. GEnie:    KITCHEN.SINK
  243.  
  244. +++++++++++++++++++++++++++
  245.  
  246. From: yjc@po.cwru.edu (Jerome Chan)
  247. Date: 12 Jul 92 22:35:31 GMT
  248. Organization: Alethea, The Twilight World!
  249.  
  250. In article <1992Jul12.215354.4769@magnus.acs.ohio-state.edu> J Eric Bush,
  251. jbush@magnus.acs.ohio-state.edu writes:
  252. >The cursor resource is located in the Finder, not in the System file.  I
  253. have
  254. >done this within applications by copying the cursors from the Finder to
  255. my
  256. >applications resource fork and then using SetCursor() from within Think
  257. Pascal.
  258.  
  259.   Is there a way we can use the "acur" resources to do this job? Since
  260. the spinning stopwatch is used by the finder to indicate a "Busy SIgnal",
  261. it seems like a waste of space for each application to have their own
  262. stopwatch cursors.
  263.  
  264.   Thanks for the reply!
  265.  
  266. - ---
  267.  Fading
  268.  
  269. ---------------------------
  270.  
  271. From: peterc@cubetech.com (Peter Creath)
  272. Subject: undocumented low-memory globals
  273. Date: 5 Jul 92 14:55:41 GMT
  274. Organization: Cube Technologies
  275.  
  276. How does one determine the function of an undocumented low-memory
  277. global?  I know I'm not supposed to use them, but I need to find out
  278. what one does...
  279.  
  280. Please send all replies via mail, and I'll post a summary...
  281.  
  282. - ----------------------------------------------------------------------------
  283. Peter Creath                 "When I was a boy I was told that anybody could
  284. peterc@cubetech.com           become president; I'm beginning to believe it."
  285.                                                            -- Clarence Darrow
  286.  
  287. +++++++++++++++++++++++++++
  288.  
  289. From: ewylie@ocf.berkeley.edu (Elizabeth Wylie)
  290. Date: 5 Jul 92 21:12:35 GMT
  291. Organization: U.C. Berkeley Open Computing Facility
  292.  
  293. Talk about flame-bait...
  294.  
  295. That's why they're called 'undocumented'.  For the most part the only way to
  296. find out what one does is to change the values and see what happens.  You should
  297. be very familiar with macsbug or tmon.
  298.  
  299. Why do you have to know?  C'mon, you can tell us.  :-)
  300.  
  301. - -E. Wylie
  302.  
  303. +++++++++++++++++++++++++++
  304.  
  305. From: ksand@apple.com (Kent Sandvik)
  306. Date: 9 Jul 92 00:17:48 GMT
  307. Organization: Apple Inc, Debugging Department
  308.  
  309. In article <137ok3INNojv@agate.berkeley.edu>, ewylie@ocf.berkeley.edu
  310. (Elizabeth Wylie) wrote:
  311. > That's why they're called 'undocumented'.  For the most part the only way to
  312. > find out what one does is to change the values and see what happens.  You should
  313. > be very familiar with macsbug or tmon. 
  314. > Why do you have to know?  C'mon, you can tell us.  :-)
  315.  
  316. The other nice feature with undocumented lmg:s is that they might
  317. suddenly disappear or change, as in System 7.1 or future releases. 
  318. To be secure concerning future platforms and PowerPC environments,
  319. please avoid them, use API:s, and if something is missing, send
  320. us an email because every lmg which needs to be accessed officially
  321. should have an API.
  322.  
  323. Have fun!
  324.  
  325. Kent/DTS
  326.  
  327. +++++++++++++++++++++++++++
  328.  
  329. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  330. Date: 9 Jul 92 05:22:04 GMT
  331. Organization: University of Waikato, Hamilton, New Zealand
  332.  
  333. In article <ksand-080792171813@90.133.12.38>, ksand@apple.com (Kent Sandvik) writes:
  334. > The other nice feature with undocumented lmg:s is that they might
  335. > suddenly disappear or change, as in System 7.1 or future releases.
  336. > To be secure concerning future platforms and PowerPC environments,
  337. > please avoid them, use API:s, and if something is missing, send
  338. > us an email because every lmg which needs to be accessed officially
  339. > should have an API.
  340.  
  341. OK, here's one that comes to mind: there's no way to find menus by name,
  342. other than by directly searching the MenuList!
  343.  
  344. I needed this for a set of MPW tools I wrote that let me set up a nicer
  345. "Directory" menu and hierarchical custom menus in the MPW Shell.
  346.  
  347. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  348. Computer Services Dept                     fax: +64-7-838-4066
  349. University of Waikato            electric mail: ldo@waikato.ac.nz
  350. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  351.                        Signature tow-away zone. You have been wa
  352.  
  353. +++++++++++++++++++++++++++
  354.  
  355. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  356. Date: 9 Jul 92 10:58:29 GMT
  357. Organization: Royal Institute of Technology, Stockholm, Sweden
  358.  
  359. .ac.nz> ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  360.  
  361.    OK, here's one that comes to mind: there's no way to find menus by name,
  362.    other than by directly searching the MenuList!
  363.  
  364. You shouldn't anyway, since the menu names changes between different
  365. countries.
  366.  
  367. - -- 
  368.          Jon W{tte, Svartmangatan 18, S-111 29 Stockholm, Sweden
  369.  
  370. ### You have the Easy Access virus. This virus may cause strange sounds
  371. ### and weird keyboard behaviour when you press the shift key repeatedly.
  372.  
  373. +++++++++++++++++++++++++++
  374.  
  375. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  376. Date: 10 Jul 92 17:18:38 +1200
  377. Organization: University of Waikato, Hamilton, New Zealand
  378.  
  379. In article <D88-JWA.92Jul9115829@dront.nada.kth.se>, d88-jwa@dront.nada.kth.se (Jon W{tte) writes:
  380. > .ac.nz> ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  381. >
  382. >    OK, here's one that comes to mind: there's no way to find menus by name,
  383. >    other than by directly searching the MenuList!
  384. >
  385. > You shouldn't anyway, since the menu names changes between different
  386. > countries.
  387.  
  388. Here's the other paragraph from my original posting, that you forgot to
  389. quote:
  390.  
  391. >>I needed this for a set of MPW tools I wrote that let me set up a nicer
  392. >>"Directory" menu and hierarchical custom menus in the MPW Shell.
  393.  
  394. Custom MPW menus are set up using the Shell script commands AddMenu and
  395. DeleteMenu. The names of the menus (and of the menu items) are chosen by the
  396. user. My commands are intended to work as similarly as possible to AddMenu
  397. and DeleteMenu, by allowing you to specify the names of menus and menu items.
  398. I would *assume* that, whatever names they gave the menus, in whatever language,
  399. they would use the same names when invoking my tools to manipulate those
  400. menus.
  401.  
  402. Lawrence
  403. not quite as dumb as he looks. :-)
  404.  
  405. +++++++++++++++++++++++++++
  406.  
  407. From: gurgle@netcom.com (Pete Gontier)
  408. Date: 10 Jul 92 07:25:40 GMT
  409. Organization: cellular
  410.  
  411. ksand@apple.com (Kent Sandvik) writes:
  412. >The other nice feature with undocumented lmg:s is that they might
  413. >suddenly disappear or change, as in System 7.1 or future releases. 
  414.  
  415. When I see what MemError resolves to, I am dismayed of ever seeing
  416. a "protected" MacOS, even in System 9.0.
  417.  
  418. >To be secure concerning future platforms and PowerPC environments,
  419. >please avoid them, use API:s, and if something is missing, send
  420. >us an email because every lmg which needs to be accessed officially
  421. >should have an API.
  422.  
  423. The lack of a GetMBarHeight comes to mind. THINK C 4 had it. 5 still has
  424. it, if you go out of your way to include headers which explicitly are
  425. not part of the "official" group of MPW-style headers. I suppose
  426. GhostWindow is another, but only Illustrator uses it. Probably there
  427. are all sorts of LMGs which could stand an API.
  428. - -- 
  429.  Pete Gontier // EC Technology // gurgle@netcom.com
  430.  
  431. +++++++++++++++++++++++++++
  432.  
  433. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  434. Date: 15 Jul 92 18:53:45 +1200
  435. Organization: University of Waikato, Hamilton, New Zealand
  436.  
  437. In article <1992Jul9.172204.9260@waikato.ac.nz>, I said:
  438. > In article <ksand-080792171813@90.133.12.38>, ksand@apple.com (Kent Sandvik) writes:
  439. >> The other nice feature with undocumented lmg:s is that they might
  440. >> suddenly disappear or change, as in System 7.1 or future releases.
  441. >> To be secure concerning future platforms and PowerPC environments,
  442. >> please avoid them, use API:s, and if something is missing, send
  443. >> us an email because every lmg which needs to be accessed officially
  444. >> should have an API.
  445. >
  446. > OK, here's one that comes to mind: there's no way to find menus by name,
  447. > other than by directly searching the MenuList!
  448. >
  449. > I needed this for a set of MPW tools I wrote that let me set up a nicer
  450. > "Directory" menu and hierarchical custom menus in the MPW Shell.
  451.  
  452. Let me amend my original wish: what I really want is a way of indexing
  453. through all the menus in each half of the MenuList. That is, I want to be
  454. able to find all top-level menus (the ones whose titles appear in the menu bar)
  455. by index, and I want to be able to scan all hierarchial/popup menus in the same
  456. way. I can use the documented structure of a menu handle to pull out the menu
  457. title and check it myself.
  458.  
  459. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  460. Computer Services Dept                     fax: +64-7-838-4066
  461. University of Waikato            electric mail: ldo@waikato.ac.nz
  462. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  463. This disclaimer that this posting represents the sole viewpoint of
  464. the author and not that of the University of Waikato is not the
  465. official University of Waikato disclaimer; it is entirely the work
  466. of the author.
  467.  
  468. ---------------------------
  469.  
  470. From: paul@svl.cdc.com (Paul Kohlmiller)
  471. Subject: MPW on SE
  472. Date: 7 Jul 92 00:22:54 GMT
  473.  
  474. I made the plunge to MPW by getting ETO. Now I see that I have to upgrade
  475. my Mac from an SE and I've already figured out that it is better and
  476. probably cheaper to get a MAC LC II. Fine.
  477. I also know that my 4meg RAM on the SE is never going to work with MacAPP
  478. and I can live with that for a while. I got MPW C to compile "hello,world".
  479. I cannot get MPW C++ to compile the simple examples that come with it. I
  480. get the same error that I get with MacApp - a bomb box that says the
  481. application failed with error #2. Does this mean I can't use MPW C++ on an
  482. SE with 4 megs? Or does this mean I did something else wrong. I am using
  483. System 6.0.7 with and without MF. I will try system 7 as well.
  484. All clues accepted.
  485. BTW, an earlier post said that MPW was a career choice not a programming
  486. choice. That was true for me, I saw the ads that asked for MPW programmers
  487. and decided my career was somewhere down that path.
  488. Another earlier post discussed Symantec's plans for Think C++. I'm sure that
  489. is why (or part of why) they bought Zortech. Think C will never be C++.
  490. There may come a time when Zortech C++ does not need MPW but life was too
  491. short to wait so I did the ETO think.
  492.  
  493. - --
  494.      // Paul H. Kohlmiller           //  "Cybers, Macs and Mips"      //
  495.      // Control Data Corporation     // Internet: paul@svl.cdc.com   //
  496.      // All comments are strictly    // America Online: Paul CDC    //
  497.      // my own.                      //                            // 
  498.  
  499. +++++++++++++++++++++++++++
  500.  
  501. From: ksand@apple.com (Kent Sandvik)
  502. Date: 8 Jul 92 23:36:25 GMT
  503. Organization: Apple Inc, Debugging Department
  504.  
  505. In article <44708@shamash.cdc.com>, paul@svl.cdc.com (Paul Kohlmiller)
  506. wrote:
  507. > I also know that my 4meg RAM on the SE is never going to work with MacAPP
  508. > and I can live with that for a while. I got MPW C to compile "hello,world".
  509. > I cannot get MPW C++ to compile the simple examples that come with it. I
  510. > get the same error that I get with MacApp - a bomb box that says the
  511. > application failed with error #2. Does this mean I can't use MPW C++ on an
  512. > SE with 4 megs? Or does this mean I did something else wrong. I am using
  513. > System 6.0.7 with and without MF. I will try system 7 as well.
  514. > All clues accepted.
  515.  
  516. If I remember correctly the latest MPW C++ was compiled with the 68020
  517. flags, so it won't work with 68000 based Macs. Sorry, I guess this 
  518. was an issue where the needs of the many outweighted the needs of the
  519. few (power users vs. entry level users concerning C++). Also the
  520. latest MPW shell is compiled with 68020 flags.
  521.  
  522. Sometimes familiarity with MPW is good for certain Macintosh oriented jobs,
  523. however I do think that a good UNIX user should get up to speed with MPW
  524. quickly.
  525.  
  526. I would recommend to use Think C anyway, because their object oriented
  527. C compiler is not really C++, but it compiles and links fast on an SE.
  528. I tried once to compile/link Nothing.cp on an SE back home, it took 34
  529. minutes with a 4Mb SE... This was the MPW C++ 3.1, which should work
  530. with SEs.
  531.  
  532. As for career, I think the main issue is C/C++ and any object framework
  533. design/use. MacApp or TCL are good starting points for future other
  534. frameworks (Bedrock, Pink, anything skanky from Seattle...). 
  535. Or do as the macho OOP programmers -- write your own framework :-).
  536.  
  537. Cheers,
  538. Kent/DTS
  539.  
  540. +++++++++++++++++++++++++++
  541.  
  542. From: rich@grayhawk.rent.com (Richard Harms)
  543. Date: 14 Jul 92 07:06:17 GMT
  544. Organization: Des Moines, Iowa, Public Access Unix; 515/277-6753
  545.  
  546. In article <ksand-080792163306@90.133.12.38> ksand@apple.com (Kent Sandvik) writes:
  547. >If I remember correctly the latest MPW C++ was compiled with the 68020
  548. >flags, so it won't work with 68000 based Macs. Sorry, I guess this 
  549. >was an issue where the needs of the many outweighted the needs of the
  550. >few (power users vs. entry level users concerning C++). Also the
  551. >latest MPW shell is compiled with 68020 flags.
  552.  
  553. Annoyingly, the MPW Shell which is able to use toolserver won't work on 
  554. 68K machine either (I have an older portable which I used to run just the
  555. shell on, with an older toolserver-aware mpw, and have it tell my IIfx to
  556. compile and set the output to it... used to be convenient, but I guess that's
  557. out now (I really wish it weren't... just a shell using a real machine to 
  558. compile code on is a good use for old 68k machines. :) ))
  559.  
  560. - -rh
  561.  
  562. - -- 
  563. Richard R. Harms            Internet: r-harms@grayhawk.rent.com 
  564. 1217 24th, Suite 49             UUCP: {...}!{rutgers!bobsbox}!grayhawk!rich
  565. Des Moines, Iowa 50311       AOnline: Grayhawk             AppleLink: D2656 
  566.                                  Fax: 515/884-2736       Unix: 515/277-6753
  567.  
  568. ---------------------------
  569.  
  570. From: de19@umail.umd.edu (Dana S Emery)
  571. Subject: MPW Scripting Q - answer
  572. Date: 9 Jul 92 07:32:03 GMT
  573. Organization: Personal
  574.  
  575. # I was being done in by some *Interesting* behaviour of the shell.
  576.  
  577. # To recap, I am attempting to port some Think C code to my Think C 
  578. # environment.  I had hoped to use MPW script to compensate for
  579. # the unusual file disposition expected by the code.  Certain
  580. # include "xxx" had to become #include <xxx>.  Since I am taking
  581. # advantage of the Think search strategy which ignores folders
  582. # whose name is (xxx) [as in Drive:Project:Source:(oldSource):WontBeSeen]
  583. # it is necessary for me to edit the file list.
  584.  
  585. # The following skeleton shows Flow:
  586.  
  587. Directory 'Disk:Project:'
  588. Search >'Disk:Work' /#include ../ `Files .. | Search -r /.../ | Search /.../`
  589.  
  590. #Since my home machine has a 9: screen, I broke the lines:
  591.  
  592. #  NOTE    (d => option-d)
  593.  
  594. Directory 'Disk:Project:'            # OK, but the rest fails
  595. Search >'Disk:Work' /#include ../ d
  596. `Files .. d
  597. | Search -r /.../ d
  598. | Search /.../`
  599.  
  600. # That was the source of my greifs.  The following works
  601.  
  602. Directory 'Disk:Project:'
  603. Search >'Disk:Work' /#include ../ `Files -r -s -f -t TEXT | Search d
  604. - -r /.../ | Search d
  605. /.../`
  606.  
  607. # The resulting 300 lines have been printed, and are driving a semi-manual 
  608. # corection process.  I would have loved to have automated that as well,
  609. # but I dont want to waste any more time on what murphy will throw at me
  610. # next.  (he and I have a long relationship).
  611.  
  612. # I dont know why the line continuation upsets the interpretation of the
  613. # pipe, perhaps it has to do with relative parseing priority of | and d, but 
  614. # it seems necessary for the pipe and the right hand *verb* to be on the same
  615. # line as the left *verb* for the binding to take place.
  616.  
  617. # Would have been nice if this had been discussed in the manual.(sigh)
  618.  
  619. I will be glad to Email/ftp a binhex of the actual script for any one who
  620. really wants it.
  621.  
  622. Thanks to all who responded with advice, except for the one individual
  623. who just *had* to advocate Pearl.
  624.  
  625. - --
  626. Dana S Emery (de19@umail.umd.edu)
  627.  
  628. +++++++++++++++++++++++++++
  629.  
  630. From: neeri@iis.ethz.ch (Matthias Neeracher)
  631. Organization: Integrated Systems Laboratory, ETH, Zurich
  632. Date: Fri, 10 Jul 1992 16:22:21 GMT
  633.  
  634. In article <14359@umd5.umd.edu> de19@umail.umd.edu (Dana S Emery) writes:
  635. ># That was the source of my greifs.  The following works
  636. >
  637. >Directory 'Disk:Project:'
  638. >Search >'Disk:Work' /#include ../ `Files -r -s -f -t TEXT | Search d
  639. >-r /.../ | Search d
  640. >/.../`
  641. >
  642. ># The resulting 300 lines have been printed, and are driving a semi-manual 
  643. ># corection process.  I would have loved to have automated that as well,
  644. ># but I dont want to waste any more time on what murphy will throw at me
  645. ># next.  (he and I have a long relationship).
  646. >[...]
  647. >Thanks to all who responded with advice, except for the one individual
  648. >who just *had* to advocate Pearl.
  649.  
  650. Hey, bash my advice all you want, but at least spell "Perl" right. I don't want
  651. to be on the record as advocating a Pascal based Real Time programming language
  652. for text searching problems.
  653.  
  654. Matthias
  655.  
  656. BTW, I still believe that Perl would be suited very well to this task.
  657.  
  658. - -----
  659. Matthias Neeracher                                   neeri@iis.ethz.ch
  660.    "There once was an Age of Reason, but we've progressed beyond it."
  661.                                    -- Ayn Rand, _Atlas Shrugged_
  662.  
  663. +++++++++++++++++++++++++++
  664.  
  665. From: sdorner@qualcom.qualcomm.com (Steve Dorner)
  666. Organization: Qualcomm, Inc., San Diego, CA
  667. Date: Wed, 15 Jul 1992 03:42:14 GMT
  668.  
  669. neeri@iis.ethz.ch (Matthias Neeracher) writes:
  670. >In article <14359@umd5.umd.edu> de19@umail.umd.edu (Dana S Emery) writes:
  671. >>Thanks to all who responded with advice, except for the one individual
  672. >>who just *had* to advocate Pearl.
  673. >Hey, bash my advice all you want, but at least spell "Perl" right.
  674.  
  675. "Cast not thy perl before swine, lest they turn and rend you."  :-)
  676.  
  677. Matthias' MPW perl port is the best thing that could possibly have
  678. happened to MPW.  I can live with MPW as a programming environment
  679. now.
  680. - -- 
  681. Steve Dorner, Qualcomm, Inc.
  682. Yes, I'm still working on Eudora and it's still free.
  683.  
  684. ---------------------------
  685.  
  686. From: davidp@calvin.usc.edu (David Peterson)
  687. Subject: Debugger for daemons?
  688. Date: 9 Jul 92 21:01:50 GMT
  689. Organization: University of Southern California, Los Angeles, CA
  690.  
  691.  
  692. Is there a source-level debugger (or something I can do to SADE
  693. or SourceBug) that will let me debug faceless background apps?
  694.  
  695. I can start the thing in SourceBug and set breakpoints, but when
  696. I try to single step all the windows go blank and I can't tell
  697. whats going on.
  698.  
  699. SADE won't even launch a daemon.
  700.  
  701. Thanks,
  702. - -dave.
  703.  
  704. +++++++++++++++++++++++++++
  705.  
  706. From: mspace@netcom.com (Brian Hall)
  707. Date: Fri, 10 Jul 92 06:36:36 GMT
  708. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  709.  
  710. davidp@calvin.usc.edu (David Peterson) writes:
  711.  
  712.  
  713. >Is there a source-level debugger (or something I can do to SADE
  714. >or SourceBug) that will let me debug faceless background apps?
  715.  
  716. >I can start the thing in SourceBug and set breakpoints, but when
  717. >I try to single step all the windows go blank and I can't tell
  718. >whats going on.
  719.  
  720. This may not help much, but I found the way to debug an 'appe' in Think
  721. C is to change the type to 'APPL' and make sure the 'background only' bit
  722. is NOT set.  Then I use the Think Debugger as usual.  Just don't try to
  723. run your appe when it is in this state w/o the debugger.
  724.  
  725. - -- 
  726.  
  727.  \ | /   | Brian Hall                 mspace@netcom.com
  728.  - : -   | Mark/Space Softworks       Applelink: markspace
  729.   /|\    |                            America Online: MarkSpace
  730.  |-+-|   |
  731. /-\|/-\  | People don't kill people, toasters kill people.
  732.  
  733. +++++++++++++++++++++++++++
  734.  
  735. From: sold@kit.uni-kl.de (Christoph Sold)
  736. Organization: Universitaet Kaiserslautern
  737. Date: Tue, 14 Jul 1992 17:43:48 GMT
  738.  
  739. In article <l5pa9uINNebg@calvin.usc.edu> davidp@calvin.usc.edu (David Peterson) writes:
  740. >From: davidp@calvin.usc.edu (David Peterson)
  741. >Subject: Debugger for daemons?
  742. >Date: 9 Jul 1992 14:01:50 -0700
  743.  
  744.  
  745. >Is there a source-level debugger (or something I can do to SADE
  746. >or SourceBug) that will let me debug faceless background apps?
  747.  
  748. >I can start the thing in SourceBug and set breakpoints, but when
  749. >I try to single step all the windows go blank and I can't tell
  750. >whats going on.
  751.  
  752. >SADE won't even launch a daemon.
  753.  
  754. >Thanks,
  755. >-dave.
  756.  
  757. Try Nosy/The Debugger from Jasik Designs (depending on your development 
  758. system, this should work with everything.
  759.  
  760. - -Christoph
  761. sold@kit.uni-kl.de
  762.  
  763. Christoph P. Sold                   CATS Software GmbH
  764.                                     Mussbacher Landstr.2
  765.                                     W-6730 Neustadt (Weinstrasse)
  766. ger.xse0035@applelink.apple.com     Germany
  767.  
  768. "If an apple is fun, what the heck is an appletree?"
  769.  
  770. ---------------------------
  771.  
  772. Organization: Carnegie Mellon, Pittsburgh, PA
  773. Date: Sun, 12 Jul 1992 18:06:16 -0400 
  774. From: Brian Campbell <bc2k+@andrew.cmu.edu>
  775. Subject: Dragging Icons...HELP!
  776.  
  777.     I am currently writing code (in Think C) for a graphical user
  778. interface on the Mac.  The program is for mechanical (dynamic) system
  779. modeling (i.e., it's a circuit simulator).  I currently have the core of
  780. the program done... the user selects a tool (mass, spring, damper, etc)
  781. from a tool palette, plots it down in in a grid, clicks on the icon's
  782. handles, and makes connections.
  783.  
  784.     I am now to the point where I need to make the program more user
  785. friendly (by conforming to the Mac User Interface Guidelines), and I
  786. would like to be able to click on an icon (defined as a resource) with
  787. the pointer (from the tool palette) and drag it to a new location (the
  788. standard Mac click & drag).  The pointer should drag the outline of the
  789. icon as well as the connecting lines to the other icons.  Unfortunately,
  790. I cannot find a book that explains how to do this, so I was hoping that
  791. someone out in net-land could help me.
  792.  
  793.     An example of source code that performs a similar function would be ideal.
  794.     
  795. Thanks in advance.
  796.  
  797. ******************************************************************************
  798. Brian
  799. bc2k@andrew.cmu.edu (until 8/14)
  800. bjc2d@kelvin.seas.virginia.edu (permanent)
  801.  
  802. +++++++++++++++++++++++++++
  803.  
  804. From: Andreas Wuertz <wuertz@systech.tik.ethz.ch>
  805. Organization: Swiss Federal Institute of Technology, TIK
  806. Date: Tue, 14 Jul 1992 11:54:27 GMT
  807.  
  808. In article <YeM_nMe00iUyA2VFBB@andrew.cmu.edu> Brian Campbell,
  809. bc2k+@andrew.cmu.edu writes:
  810. >standard Mac click & drag).  The pointer should drag the outline of the
  811. >icon as well as the connecting lines to the other icons.  Unfortunately,
  812. >I cannot find a book that explains how to do this, so I was hoping that
  813. >someone out in net-land could help me.
  814.  
  815. Since 32-Bit QD there is a trap called BitmapToRgn or so. Do this with
  816. icon's bitmap, add the other items (OpenRgn and then draw all items, the
  817. CloseRgn, then UnionRgn with the icon's region). Then DragGrayRgn
  818. (windowmgr, i think) to drag the outline around. If you want to support
  819. macs/systems without 32-bit QD (built into sys 7), you can get a linkable
  820. object of BitmapToRgn from DTS (developper technical support).
  821.  
  822. Hope this helps.  Andy
  823.  
  824. Andy from TIK
  825.  
  826. =======================================================
  827. The earliest time for a program to be bug-free is,
  828. when it's out of date. The latest time for a programmer
  829. to retire is, when he writes such a program.
  830. =======================================================
  831.  
  832. ---------------------------
  833.  
  834. From: robichau@lambda.msfc.nasa.gov (Paul Robichaux)
  835. Subject: DSAT error #28, ThinkPascal, and MacsBug (weird)
  836. Date: 10 Jul 92 13:58:49 GMT
  837. Organization: New Technology, Inc.
  838.  
  839. I've been developing a Think Pascal-based application at home, and
  840. have finally gotten it to work well enough to make a standalone
  841. version.
  842.  
  843. Lo and behold: when I fired it up this morning, I was suddenly
  844. staring at MacsBug, which was complaining of a system error 28 - the
  845. infamous heap/stack collision.
  846.  
  847. Here's a code fragment showing where the error occurs:
  848.  
  849. procedure ReadMyDataFile (aFile: FSSpec;
  850.             var aList: MyDataListRec;
  851.             refNum: integer);
  852.  
  853. var        
  854.     numBytes: longint;
  855.     aMyData: MyDataHandle;
  856.     tempMyData: MyDataDataRec;
  857.     recSize, idx: integer;        
  858.     anErr: OSErr;        
  859.     tempRunData: testDataArray;
  860.     ok: boolean;
  861.  
  862. begin    
  863.     debugStr('In ReadMyDataFile.;ATRA');
  864.  
  865.     { when I issue a 'g' in macsBug, I crash before reaching this line }
  866.     anErr := SetFPos(RefNum, fsFromStart, 0);
  867.  
  868.     { I never see this line here! }
  869.     debugStr('back from SetFPos.');    
  870.  
  871.     if anErr = noErr then
  872.     begin
  873.       ...
  874.       ...
  875.  
  876. MacsBug comes up with the debugStr message, and acknowledges that A-trap
  877. recording is on. Subsequent use of the 's' command admits that 'step (into)'
  878. was executed, then boom:
  879.  
  880.     system error #28 at 4080A2C6  _VRemove + 0046
  881.  
  882. Using ATP doesn't help, since no traps were recorded. I can't for the life of
  883. me figure out why SetFPos would cause a heap collision.
  884.  
  885. Another oddity: using 'hc' after the system error asserts that the app heap
  886. is OK. Does this mean that my system heap is broken? What the hell can I do
  887. about _that_?
  888.  
  889. Any and all comments (even those including the phrase "every *real* Mac
  890. programmer knows that...") are welcome. I'll post a summary once I either find
  891. the fix or get help from the net.
  892.  
  893.  
  894. Bewitched, bewildered, and _definitely_ bothered,
  895. - -Paul
  896. - -- 
  897. Paul Robichaux, KD4JZG          | NTI doesn't pay for my opinions, and NASA
  898. robichau@lambda.msfc.nasa.gov   | doesn't know I have any.
  899.          This message printed on recycled phosphors.
  900.  
  901. +++++++++++++++++++++++++++
  902.  
  903. From: siegel@world.std.com (Rich Siegel)
  904. Date: 10 Jul 92 14:35:09 GMT
  905. Organization: GCC Technologies
  906.  
  907. In article <1992Jul10.135849.5505@lambda.msfc.nasa.gov> robichau@lambda.msfc.nasa.gov writes:
  908. >I've been developing a Think Pascal-based application at home, and
  909. >have finally gotten it to work well enough to make a standalone
  910. >version.
  911. >
  912. >Lo and behold: when I fired it up this morning, I was suddenly
  913. >staring at MacsBug, which was complaining of a system error 28 - the
  914. >infamous heap/stack collision.
  915. >
  916. >Here's a code fragment showing where the error occurs:
  917. >
  918. >procedure ReadMyDataFile (aFile: FSSpec;
  919. >            var aList: MyDataListRec;
  920. >            refNum: integer);
  921. >
  922. >var        
  923. >    numBytes: longint;
  924. >    aMyData: MyDataHandle;
  925. >    tempMyData: MyDataDataRec;
  926. >    recSize, idx: integer;        
  927. >    anErr: OSErr;        
  928. >    tempRunData: testDataArray;
  929. >    ok: boolean;
  930.  
  931. Depending on the size of "tempRunData", you may be trying to allocate too
  932. much on the stack. The reason this works at home and not at work is because
  933. your home machine is probably a Color Quickdraw-capable machine, which
  934. has a larger default stack size, and your machine at work is not. If
  935. you bump up the stack size setting in the Run Options dialog, this will
  936. be incorporated into the built application.
  937.  
  938. .
  939. - -- 
  940. - -----------------------------------------------------------------------
  941. Rich Siegel                              Internet: siegel@world.std.com
  942. Software Engineer & Toolsmith
  943. GCC Technologies
  944.  
  945. +++++++++++++++++++++++++++
  946.  
  947. From: robichau@lambda.msfc.nasa.gov (Paul Robichaux)
  948. Date: 10 Jul 92 15:04:52 GMT
  949. Organization: New Technology, Inc.
  950.  
  951. In <Br6GIL.DAA@world.std.com> siegel@world.std.com (Rich Siegel) writes:
  952. >Depending on the size of "tempRunData", you may be trying to allocate too
  953. >much on the stack. The reason this works at home and not at work is because
  954. >your home machine is probably a Color Quickdraw-capable machine, which
  955. >has a larger default stack size, and your machine at work is not. If
  956. >you bump up the stack size setting in the Run Options dialog, this will
  957. >be incorporated into the built application.
  958.  
  959. I guess I was unclear (not the first time, either :) about my
  960. configuration. This app has only been run on my home machine
  961. (IIci/5/520 with a Futura SX card), and I have the zone size at 768k
  962. and the stack size at 384k (last time I looked, anyway.) I'll bump it
  963. up and adjust the SIZE resource and try again.
  964.  
  965. Since you're here, Rich :) - why doesn't this behavior appear in the
  966. TP environment?
  967.  
  968. - -Paul
  969. - -- 
  970. Paul Robichaux, KD4JZG          | NTI doesn't pay for my opinions, and NASA
  971. robichau@lambda.msfc.nasa.gov   | doesn't know I have any.
  972.          This message printed on recycled phosphors.
  973.  
  974. +++++++++++++++++++++++++++
  975.  
  976. From: siegel@world.std.com (Rich Siegel)
  977. Organization: GCC Technologies
  978. Date: Fri, 10 Jul 1992 17:18:12 GMT
  979.  
  980. In article <1992Jul10.150452.7481@lambda.msfc.nasa.gov> robichau@lambda.msfc.nasa.gov writes:
  981.  
  982. >why doesn't this behavior appear in the
  983. >TP environment?
  984.  
  985. because under the environment, the space allocated for the program to run
  986. in is the sum of the stack and zone sizes. The system only allocates space
  987. for your program based on the SIZE resource, which has to take into
  988. account that sum.
  989.  
  990. You would be well-advised to reconsider your stack size requirements,
  991. and perhaps allocate your local buffer dynamically. With a few exceptions,
  992. there's usually not much reason to need more than about 32K of stack.
  993.  
  994. R.
  995.  
  996. - -- 
  997. - -----------------------------------------------------------------------
  998. Rich Siegel                              Internet: siegel@world.std.com
  999. Software Engineer & Toolsmith
  1000. GCC Technologies
  1001.  
  1002. +++++++++++++++++++++++++++
  1003.  
  1004. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  1005. Organization: Symantec Corp.
  1006. Date: Sat, 11 Jul 1992 14:00:03 GMT
  1007.  
  1008. >>>>> On Fri, 10 Jul 1992 14:35:09 GMT, siegel@world.std.com (Rich Siegel) said:
  1009.  
  1010.  > If you bump up the stack size
  1011.  > setting in the Run Options dialog, this will be incorporated into
  1012.  > the built application.
  1013.  
  1014. Unless you're using $I-. If you turn off Pascal's initializations,
  1015. then you will get the Run Options stack in Pascal, but you will not
  1016. get it in the built app. If you need to use $I-, then you'll have to
  1017. adjust the stack yourself using SetApplLimit
  1018. - --
  1019.    Phil Shapiro                                   Software Engineer
  1020.    Language Products Group                     Symantec Corporation
  1021.            Internet: phils@cs.brandeis.edu
  1022.  
  1023. +++++++++++++++++++++++++++
  1024.  
  1025. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  1026. Organization: Symantec Corp.
  1027. Date: Sat, 11 Jul 1992 14:01:59 GMT
  1028.  
  1029. >>>>> On Fri, 10 Jul 1992 14:35:09 GMT, siegel@world.std.com (Rich Siegel) said:
  1030.  
  1031.  > If you bump up the stack size setting in the Run Options dialog,
  1032.  > this will be incorporated into the built application.
  1033.  
  1034. Unless you're using $I-. If you turn off Pascal's initializations,
  1035. then you will get the Run Options stack in Pascal, but you will not
  1036. get it in the built app. If you need to use $I-, then you'll have to
  1037. adjust the stack yourself using SetApplLimit. I believe that the TCL
  1038. has code to adjust the stack, if you're looking for an example.
  1039.  
  1040.     -phil
  1041. - --
  1042.    Phil Shapiro                                   Software Engineer
  1043.    Language Products Group                     Symantec Corporation
  1044.            Internet: phils@cs.brandeis.edu
  1045.  
  1046. ---------------------------
  1047.  
  1048. From: erh0362@tesla.njit.edu (Elliotte Rusty Harold)
  1049. Subject: When to HLock (and not HLock) handles
  1050. Date: 11 Jul 92 21:14:37 GMT
  1051. Organization: New Jersey Institute of Technology
  1052.  
  1053.  
  1054.     When should I and when shouldn't I lock a handle?  I gather that if
  1055. I'm going to do something like myPointer = *myHandle I should 
  1056. HLock(myHandle) and keep it locked until I'm finished with myPointer.  
  1057. However I'm using the technique described in Stephen Chernicoff's Mac 
  1058. Revealed Vol II to store a handle to a structure containing all sorts of 
  1059. information about a window's contents in the window's RefCon field.  The 
  1060. window data structure contains, ints, booleans, and an array of pointers to
  1061. chars, i.e. a two-dimensional array of chars.  In particular when  I want 
  1062. to do something like 
  1063.  
  1064.     dataHandle = (WDHandle) GetWRefCon(gLifeWindow);
  1065.     myArray = (**dataHandle).structArray;
  1066.  
  1067. do I need to lock dataHandle before I start doing things to myArray?
  1068. And, since myArray is a pointer to a pointer, i.e. a handle, am I
  1069. ever going to need to lock it down or will the Memory Manager leave it
  1070. alone since it was not created by NewHandle but instead was 
  1071. initially declared as an array of pointers each one of which was 
  1072. separately allocated.  
  1073.  
  1074. Elliotte Rusty Harold        Department of Applied Mathematics
  1075. elharo@m.njit.edu        New Jersey Institute of Technology
  1076. erh0362@tesla.njit.edu        Newark, NJ 07103
  1077.  
  1078. +++++++++++++++++++++++++++
  1079.  
  1080. From: fry@tara.harvard.edu (David Fry)
  1081. Date: 12 Jul 92 04:25:32 GMT
  1082. Organization: Harvard Math Department
  1083.  
  1084. In article <1992Jul11.161437.1@tesla.njit.edu> erh0362@tesla.njit.edu (Elliotte Rusty Harold) writes:
  1085. >
  1086. >    When should I and when shouldn't I lock a handle?  I gather that if
  1087. >I'm going to do something like myPointer = *myHandle I should 
  1088. >HLock(myHandle) and keep it locked until I'm finished with myPointer.  
  1089.  
  1090. That's basically it.  But you only need to do this if memory might
  1091. move, and try not to keep your handle locked longer than necessary.
  1092.  
  1093. >However I'm using the technique described in Stephen Chernicoff's Mac 
  1094. >Revealed Vol II to store a handle to a structure containing all sorts of 
  1095. >information about a window's contents in the window's RefCon field.  The 
  1096. >window data structure contains, ints, booleans, and an array of pointers to
  1097. >chars, i.e. a two-dimensional array of chars.  In particular when  I want 
  1098. >to do something like 
  1099. >
  1100. >    dataHandle = (WDHandle) GetWRefCon(gLifeWindow);
  1101. >    myArray = (**dataHandle).structArray;
  1102. >
  1103. >do I need to lock dataHandle before I start doing things to myArray?
  1104.  
  1105. Think about it this way.  The data in your structure is somewhere in
  1106. memory.  As the Mac goes about its business, this data may be shuffled
  1107. about.  But the values won't change, of course.  All myArray is one
  1108. piece of data from that structure, so no matter how the memory moves,
  1109. myArray won't change.  
  1110.  
  1111. A problem would occur if you did this:
  1112.  
  1113.     dataHandle = (WDHandle) GetWRefCon(gLifeWindow);
  1114.     dataPtr = *dataHandle;
  1115.  
  1116. If memory moves after this, a call to (dataPtr->structArray)[2][3] 
  1117. (for instance) might be invalid because the value dataPtr now points to
  1118. something else.
  1119.  
  1120. >And, since myArray is a pointer to a pointer, i.e. a handle, am I
  1121. >ever going to need to lock it down or will the Memory Manager leave it
  1122. >alone since it was not created by NewHandle but instead was 
  1123. >initially declared as an array of pointers each one of which was 
  1124. >separately allocated.  
  1125.  
  1126. If the memory is not allocated by NewHandle (or a Toolbox routine that 
  1127. calls NewHandle), the memory manager will never move it. Your 2D array is
  1128. safe. A handle is a pointer to a pointer, but a Handle is something
  1129. allocated by the memory manager.
  1130.  
  1131. David Fry                                  fry@math.harvard.EDU
  1132. Division of Applied Sciences               fry@huma1.bitnet
  1133. Harvard University                      ...!harvard!huma1!fry
  1134. Cambridge, MA  02138            
  1135.  
  1136. ---------------------------
  1137.  
  1138. End of C.S.M.P. Digest
  1139. **********************
  1140.